from selenium.webdriver.common.by import By

from framwork.pages.base_page import BasePage


class TaskPage(BasePage):
    url = '/crm/index.php?m=task'
    btn_task_locator = (By.LINK_TEXT, '任务')  # 任务
    btn_add_task_locator = (By.LINK_TEXT, '新建任务')  # 新建任务按钮
    success_task_locator = (By.LINK_TEXT, "我的任务")
    success_add_task_locator = (
        By.CSS_SELECTOR, 'body > div.container > div.row-fluid > div > form > table > tbody > tr:nth-child(1) > th')

    def click_task_button(self):
        """任务"""
        self.click(self.btn_task_locator)

    def click_add_task_button(self):
        """新增任务"""
        self.click(self.btn_add_task_locator)

    def get_success_task_tips(self):
        """获取任务成功信息"""
        return self.find_element(self.success_task_locator).text

    def get_success_add_task_tips(self):
        """获取任务添加成功信息"""
        return self.find_element(self.success_add_task_locator).text
